<?php
/**
 * Created by PhpStorm.
 * User: L
 * Date: 2018/11/27
 * Time: 15:56
 */

namespace app\controllers\Project_1_0;


use Core\Controller;
use app\models\Project_1_0\Rice_intf as Mintf;
class Rice_intf extends Controller
{
    function Banner_intf(){
        //轮播图入口
        //index.php?action=Rice_intf&func=Banner_intf
        $Banner=new Mintf();
        $res=$Banner->banner_intf();
        if ($res){
            $code = 1;
            $message = "查询成功";
        }else{
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code"=>$code,"message"=>$message,"banner_data"=>$res);
        echo json_encode($data);
    }
    function goods_details(){
        //所有商品入口
        //index.php?action=Rice_intf&func=goods_details
        $Goods=new Mintf();
        $res=$Goods->goods_details();
        if ($res){
            $code = 1;
            $message = "查询成功";
        }else{
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code"=>$code,"message"=>$message,"goods_data"=>$res);
        echo json_encode($data);

    }
    function search_userinfo(){
             //
            //index.php?action=Rice_intf&func=search_userinfo
        $user=new Mintf();
        $res=$user->userinfo();
        if ($res){
            $code = 1;
            $message = "查询成功";
        }else{
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code"=>$code,"message"=>$message,"user_data"=>$res);
        echo json_encode($data);

    }
    function search_goods()
    {
        //商品详情
        //index.php?action=Rice_intf&func=search_goods&goods_id=
        $s_goods = new Mintf();
        $res = $s_goods->search_goods();
        if ($res) {
            $code = 1;
            $message = "查询成功";
        } else {
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code" => $code, "message" => $message, "goods_details_data" => $res);
        echo json_encode($data);
    }
    function cart(){
        //购物车
        //index.php?action=Rice_intf&func=cart&user_id=1&total=1&amount=1
        $cart= new Mintf();
        $res=$cart->cart();

        if ($res) {
            $code = 1;
            $message = "查询成功";
        } else {
            $code = -1;
            $message = "查询失败";
        }

        $data = array("code" => $code, "message" => $message, "cart_data" => $res);
        echo json_encode($data);

    }
    function search_cart(){
        //购物车
        //index.php?action=Rice_intf&func=search_cart
        $cart= new Mintf();
        $res=$cart->search_cart();

        if ($res) {
            $code = 1;
            $message = "查询成功";
        } else {
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code" => $code, "message" => $message, "search_cart_data" => $res);
        echo json_encode($data);

    }
    function  add_address(){
        //添加地址
        //index.php?action=Rice_intf&func=add_address&name=1&tel=1&address=1
        $add= new Mintf();
        $res=$add->add_address();

        if ($res) {
            $code = 1;
            $message = "添加成功";
        } else {
            $code = -1;
            $message = "添加失败";
        }

        $data = array("code" => $code, "message" => $message, "add_data" => $res);
        echo json_encode($data);


    }
    function search_address(){
        //查询地址
        //index.php?action=Rice_intf&func=search_address
        $address= new Mintf();
        $res=$address->search_address();

        if ($res) {
            $code = 1;
            $message = "查询成功";
        } else {
            $code = -1;
            $message = "查询失败";
        }
        $data = array("code" => $code, "message" => $message, "search_address_data" => $res);
        echo json_encode($data);

    }
    function order(){
        //添加订单
       //index.php?action=Rice_intf&func=add_address&amount=&paytime=&status=&recname=&rectel=&recadd=&remark=
        $add_order=new Mintf();
        $res=$add_order->add_order();
        if ($res) {
            $code = 1;
            $message = "添加成功";
        } else {
            $code = -1;
            $message = "添加失败";
        }
        $data = array("code" => $code, "message" => $message, "order_data" => $res);
        echo json_encode($data);

    }

}